<!doctype html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Redis," />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.1" />






<meta name="description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis的Set是string类型的无序集合。集合成员是唯一的，这就意味着集合中不能出现重复的数据。 &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis 中 集合是通过哈希表实现的，所以添加，删除，查找的复杂度都是O(1)。 &amp;#160;&amp;#16">
<meta name="keywords" content="Redis">
<meta property="og:type" content="article">
<meta property="og:title" content="Redis 集合(Set)">
<meta property="og:url" content="https://hcldirgit.github.io/2017/09/03/Redis/21. Redis 集合(Set)/index.html">
<meta property="og:site_name" content="失落的乐章">
<meta property="og:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis的Set是string类型的无序集合。集合成员是唯一的，这就意味着集合中不能出现重复的数据。 &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis 中 集合是通过哈希表实现的，所以添加，删除，查找的复杂度都是O(1)。 &amp;#160;&amp;#16">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2017-09-02T17:32:16.757Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Redis 集合(Set)">
<meta name="twitter:description" content="&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis的Set是string类型的无序集合。集合成员是唯一的，这就意味着集合中不能出现重复的数据。 &amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;Redis 中 集合是通过哈希表实现的，所以添加，删除，查找的复杂度都是O(1)。 &amp;#160;&amp;#16">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":0,"b2t":false,"scrollpercent":false},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://hcldirgit.github.io/2017/09/03/Redis/21. Redis 集合(Set)/"/>





  <title>Redis 集合(Set) | 失落的乐章</title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  




<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  ga('create', '85*****1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?87980c**************99ec5e26fb5";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>











  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">失落的乐章</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle">技术面前，永远都是学生。</p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-message">
          <a href="/message" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-external-link"></i> <br />
            
            留言
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <link itemprop="mainEntityOfPage" href="https://hcldirgit.github.io/2017/09/03/Redis/21. Redis 集合(Set)/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="失落的乐章">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/0.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="失落的乐章">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Redis 集合(Set)</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-03T02:09:22+08:00">
                2017-09-03
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis的Set是string类型的无序集合。集合成员是唯一的，这就意味着集合中不能出现重复的数据。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis 中 集合是通过哈希表实现的，所以添加，删除，查找的复杂度都是O(1)。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;集合中最大的成员数为 232 - 1 (4294967295, 每个集合可存储40多亿个成员)。</p>
<h2 id="实例"><a href="#实例" class="headerlink" title="实例"></a>实例</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">edis 127.0.0.1:6379&gt; SADD runoobkey redis</div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD runoobkey mongodb</div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD runoobkey mysql</div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD runoobkey mysql</div><div class="line">(<span class="built_in">integer</span>) 0</div><div class="line">redis 127.0.0.1:6379&gt; SMEMBERS runoobkey</div><div class="line"> </div><div class="line">1) <span class="string">"mysql"</span></div><div class="line">2) <span class="string">"mongodb"</span></div><div class="line">3) <span class="string">"redis"</span></div></pre></td></tr></table></figure>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在以上实例中我们通过 <strong>SADD</strong> 命令向名为 <strong>runoobkey</strong> 的集合插入的三个元素。</p>
<h2 id="Redis-集合命令"><a href="#Redis-集合命令" class="headerlink" title="Redis 集合命令"></a>Redis 集合命令</h2><h3 id="1-Redis-Sadd-命令"><a href="#1-Redis-Sadd-命令" class="headerlink" title="1.Redis Sadd 命令"></a>1.Redis Sadd 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SADD key member1 [member2]</code> </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>向集合添加一个或多个成员</code><br>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Sadd 命令将一个或多个成员元素加入到集合中，已经存在于集合的成员元素将被忽略。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;假如集合 key 不存在，则创建一个只包含添加的元素作成员的集合。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;当集合 key 不是集合类型时，返回一个错误。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;注意：在Redis2.4版本以前， SADD 只接受单个成员值。</p>
<h4 id="语法"><a href="#语法" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Sadd 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD KEY_NAME VALUE1..VALUEN</div></pre></td></tr></table></figure>
<h4 id="可用版本"><a href="#可用版本" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值"><a href="#返回值" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;被添加到集合中的新元素的数量，不包括被忽略的元素。</p>
<h4 id="实例-1"><a href="#实例-1" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 0</div><div class="line">redis 127.0.0.1:6379&gt; SMEMBERS myset</div><div class="line">1) <span class="string">"hello"</span></div><div class="line">2) <span class="string">"foo"</span></div></pre></td></tr></table></figure>
<h3 id="2-Redis-Scard-命令"><a href="#2-Redis-Scard-命令" class="headerlink" title="2.Redis Scard 命令"></a>2.Redis Scard 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SCARD key</code> </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>获取集合的成员数</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Scard 命令返回集合中元素的数量。</p>
<h4 id="语法-1"><a href="#语法-1" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Scard 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SCARD KEY_NAME</div></pre></td></tr></table></figure>
<h4 id="可用版本-1"><a href="#可用版本-1" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-1"><a href="#返回值-1" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;集合的数量。 当集合 key 不存在时，返回 0 。</p>
<h4 id="实例-2"><a href="#实例-2" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 0</div><div class="line">redis 127.0.0.1:6379&gt; SCARD myset</div><div class="line">(<span class="built_in">integer</span>) 2</div></pre></td></tr></table></figure>
<h3 id="3-Redis-Sdiff-命令"><a href="#3-Redis-Sdiff-命令" class="headerlink" title="3.Redis Sdiff 命令"></a>3.Redis Sdiff 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SDIFF key1 [key2]</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>返回给定所有集合的差集</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Sdiff 命令返回给定集合之间的差集。不存在的集合 key 将视为空集。</p>
<h4 id="语法-2"><a href="#语法-2" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Sdiff 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SDIFF FIRST_KEY OTHER_KEY1..OTHER_KEYN</div></pre></td></tr></table></figure>
<h4 id="可用版本-2"><a href="#可用版本-2" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-2"><a href="#返回值-2" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;包含差集成员的列表。</p>
<h4 id="实例-3"><a href="#实例-3" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"world"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SDIFF myset myset2</div><div class="line">1) <span class="string">"foo"</span></div><div class="line">2) <span class="string">"bar"</span></div></pre></td></tr></table></figure>
<h3 id="4-Redis-Sdiffstore-命令"><a href="#4-Redis-Sdiffstore-命令" class="headerlink" title="4.Redis Sdiffstore 命令"></a>4.Redis Sdiffstore 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SDIFFSTORE destination key1 [key2]</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>返回给定所有集合的差集并存储在 destination 中</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Sdiffstore 命令将给定集合之间的差集存储在指定的集合中。如果指定的集合 key 已存在，则会被覆盖。</p>
<h4 id="语法-3"><a href="#语法-3" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Sdiffstore 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SDIFFSTORE DESTINATION_KEY KEY1..KEYN</div></pre></td></tr></table></figure>
<h4 id="可用版本-3"><a href="#可用版本-3" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-3"><a href="#返回值-3" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;结果集中的元素数量。</p>
<h4 id="实例-4"><a href="#实例-4" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"world"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SDIFFSTORE destset myset myset2</div><div class="line">(<span class="built_in">integer</span>) 2</div><div class="line">redis 127.0.0.1:6379&gt; SMEMBERS destset</div><div class="line">1) <span class="string">"foo"</span></div><div class="line">2) <span class="string">"bar"</span></div></pre></td></tr></table></figure>
<h3 id="5-Redis-Sinter-命令"><a href="#5-Redis-Sinter-命令" class="headerlink" title="5.Redis Sinter 命令"></a>5.Redis Sinter 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SINTER key1 [key2]</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>返回给定所有集合的交集</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Sinter 命令返回给定所有给定集合的交集。 不存在的集合 key 被视为空集。 当给定集合当中有一个空集时，结果也为空集(根据集合运算定律)。</p>
<h4 id="语法-4"><a href="#语法-4" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Sinter 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SINTER KEY KEY1..KEYN</div></pre></td></tr></table></figure>
<h4 id="可用版本-4"><a href="#可用版本-4" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-4"><a href="#返回值-4" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;交集成员的列表。</p>
<h4 id="实例-5"><a href="#实例-5" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"world"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SINTER myset myset2</div><div class="line">1) <span class="string">"hello"</span></div></pre></td></tr></table></figure>
<h3 id="6-Redis-Sinterstore-命令"><a href="#6-Redis-Sinterstore-命令" class="headerlink" title="6.Redis Sinterstore 命令"></a>6.Redis Sinterstore 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SINTERSTORE destination key1 [key2]</code> </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>返回给定所有集合的交集并存储在 destination 中</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Sinterstore 命令将给定集合之间的交集存储在指定的集合中。如果指定的集合已经存在，则将其覆盖。</p>
<h4 id="语法-5"><a href="#语法-5" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Sinterstore 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SINTERSTORE DESTINATION_KEY KEY KEY1..KEYN</div></pre></td></tr></table></figure>
<h4 id="可用版本-5"><a href="#可用版本-5" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-5"><a href="#返回值-5" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;交集成员的列表。</p>
<h4 id="实例-6"><a href="#实例-6" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"world"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SINTERSTORE myset myset1 myset2</div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SMEMBERS myset</div><div class="line">1) <span class="string">"hello"</span></div></pre></td></tr></table></figure>
<h3 id="7-Redis-Sismember-命令"><a href="#7-Redis-Sismember-命令" class="headerlink" title="7.Redis Sismember 命令"></a>7.Redis Sismember 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SISMEMBER key member</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>判断 member 元素是否是集合 key 的成员</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Sismember 命令判断成员元素是否是集合的成员。</p>
<h4 id="语法-6"><a href="#语法-6" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Sismember 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SISMEMBER KEY VALUE</div></pre></td></tr></table></figure>
<h4 id="可用版本-6"><a href="#可用版本-6" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-6"><a href="#返回值-6" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果成员元素是集合的成员，返回 1 。 如果成员元素不是集合的成员，或 key 不存在，返回 0 。</p>
<h4 id="实例-7"><a href="#实例-7" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SISMEMBER myset1 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SISMEMBER myset1 <span class="string">"world"</span></div><div class="line">(<span class="built_in">integer</span>) 0</div></pre></td></tr></table></figure>
<h3 id="8-Redis-Smembers-命令"><a href="#8-Redis-Smembers-命令" class="headerlink" title="8.Redis Smembers 命令"></a>8.Redis Smembers 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SMEMBERS key</code> </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>返回集合中的所有成员</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Smembers 命令返回集合中的所有的成员。 不存在的集合 key 被视为空集合。</p>
<h4 id="语法-7"><a href="#语法-7" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Smembers 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SMEMBERS KEY VALUE</div></pre></td></tr></table></figure>
<h4 id="可用版本-7"><a href="#可用版本-7" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-7"><a href="#返回值-7" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;集合中的所有成员。</p>
<h4 id="实例-8"><a href="#实例-8" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"world"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SMEMBERS myset1</div><div class="line">1) <span class="string">"World"</span></div><div class="line">2) <span class="string">"Hello"</span></div></pre></td></tr></table></figure>
<h3 id="9-Redis-Smove-命令"><a href="#9-Redis-Smove-命令" class="headerlink" title="9.Redis Smove 命令"></a>9.Redis Smove 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SMOVE source destination member</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>将 member 元素从 source 集合移动到 destination 集合</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Smove 命令将指定成员 member 元素从 source 集合移动到 destination 集合。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;SMOVE 是原子性操作。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果 source 集合不存在或不包含指定的 member 元素，则 SMOVE 命令不执行任何操作，仅返回 0 。否则， member 元素从 source 集合中被移除，并添加到 destination 集合中去。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;当 destination 集合已经包含 member 元素时， SMOVE 命令只是简单地将 source 集合中的 member 元素删除。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;当 source 或 destination 不是集合类型时，返回一个错误。</p>
<h4 id="语法-8"><a href="#语法-8" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Smove 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SMOVE SOURCE DESTINATION MEMBER</div></pre></td></tr></table></figure>
<h4 id="可用版本-8"><a href="#可用版本-8" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-8"><a href="#返回值-8" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;如果成员元素被成功移除，返回 1 。 如果成员元素不是 source 集合的成员，并且没有任何操作对 destination 集合执行，那么返回 0 。</p>
<h4 id="实例-9"><a href="#实例-9" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"world"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SMOVE myset1 myset2 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SMEMBERS myset1</div><div class="line">1) <span class="string">"World"</span></div><div class="line">2) <span class="string">"Hello"</span></div><div class="line">redis 127.0.0.1:6379&gt; SMEMBERS myset2</div><div class="line">1) <span class="string">"foo"</span></div><div class="line">2) <span class="string">"bar"</span></div></pre></td></tr></table></figure>
<h3 id="10-Redis-Spop-命令"><a href="#10-Redis-Spop-命令" class="headerlink" title="10.Redis Spop 命令"></a>10.Redis Spop 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SPOP key</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>移除并返回集合中的一个随机元素</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Spop 命令用于移除并返回集合中的一个随机元素。</p>
<h4 id="语法-9"><a href="#语法-9" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Spop 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SPOP KEY</div></pre></td></tr></table></figure>
<h4 id="可用版本-9"><a href="#可用版本-9" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-9"><a href="#返回值-9" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;被移除的随机元素。 当集合不存在或是空集时，返回 nil 。</p>
<h4 id="实例-10"><a href="#实例-10" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"world"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SPOP myset1</div><div class="line"><span class="string">"bar"</span></div><div class="line">redis 127.0.0.1:6379&gt; SMEMBERS myset1</div><div class="line">1) <span class="string">"Hello"</span></div><div class="line">2) <span class="string">"world"</span></div></pre></td></tr></table></figure>
<h3 id="11-Redis-Srandmember-命令"><a href="#11-Redis-Srandmember-命令" class="headerlink" title="11.Redis Srandmember 命令"></a>11.Redis Srandmember 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SRANDMEMBER key [count]</code> </p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>返回集合中一个或多个随机数</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Srandmember 命令用于返回集合中的一个随机元素。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;从 Redis 2.6 版本开始， Srandmember 命令接受可选的 count 参数：</p>
<ul>
<li>如果 count 为正数，且小于集合基数，那么命令返回一个包含 count 个元素的数组，数组中的元素各不相同。如果 count 大于等于集合基数，那么返回整个集合。</li>
<li>如果 count 为负数，那么命令返回一个数组，数组中的元素可能会重复出现多次，而数组的长度为 count 的绝对值。</li>
</ul>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;该操作和 SPOP 相似，但 SPOP 将随机元素从集合中移除并返回，而 Srandmember 则   仅仅返回随机元素，而不对集合进行任何改动。</p>
<h4 id="语法-10"><a href="#语法-10" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Srandmember 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SRANDMEMBER KEY [count]</div></pre></td></tr></table></figure>
<h4 id="可用版本-10"><a href="#可用版本-10" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-10"><a href="#返回值-10" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;只提供集合 key 参数时，返回一个元素；如果集合为空，返回 nil 。 如果提供了 count 参数，那么返回一个数组；如果集合为空，返回空数组。</p>
<h4 id="实例-11"><a href="#实例-11" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"world"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SRANDMEMBER myset1</div><div class="line"><span class="string">"bar"</span></div><div class="line">redis 127.0.0.1:6379&gt; SRANDMEMBER myset1 2</div><div class="line">1) <span class="string">"Hello"</span></div><div class="line">2) <span class="string">"world"</span></div></pre></td></tr></table></figure>
<h3 id="12-Redis-Srem-命令"><a href="#12-Redis-Srem-命令" class="headerlink" title="12.Redis Srem 命令"></a>12.Redis Srem 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SREM key member1 [member2]</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>移除集合中一个或多个成员</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>Redis Srem 命令用于移除集合中的一个或多个成员元素，不存在的成员元素会被忽略。</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;当 key 不是集合类型，返回一个错误。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;在 Redis 2.4 版本以前， SREM 只接受单个成员值。</p>
<h4 id="语法-11"><a href="#语法-11" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Srem 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SREM KEY MEMBER1..MEMBERN</div></pre></td></tr></table></figure>
<h4 id="可用版本-11"><a href="#可用版本-11" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-11"><a href="#返回值-11" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;被成功移除的元素的数量，不包括被忽略的元素。</p>
<h4 id="实例-12"><a href="#实例-12" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"world"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SREM myset1 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SREM myset1 <span class="string">"foo"</span></div><div class="line">(<span class="built_in">integer</span>) 0</div><div class="line">redis 127.0.0.1:6379&gt; SMEMBERS myset1</div><div class="line">1) <span class="string">"bar"</span></div><div class="line">2) <span class="string">"world"</span></div></pre></td></tr></table></figure>
<h3 id="13-Redis-Sunion-命令"><a href="#13-Redis-Sunion-命令" class="headerlink" title="13.Redis Sunion 命令"></a>13.Redis Sunion 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SUNION key1 [key2]</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>返回所有给定集合的并集</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Sunion 命令返回给定集合的并集。不存在的集合 key 被视为空集。</p>
<h4 id="语法-12"><a href="#语法-12" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Sunion 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SUNION KEY KEY1..KEYN</div></pre></td></tr></table></figure>
<h4 id="可用版本-12"><a href="#可用版本-12" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-12"><a href="#返回值-12" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;并集成员的列表。</p>
<h4 id="实例-13"><a href="#实例-13" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"world"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SUNION myset1 myset2</div><div class="line">1) <span class="string">"bar"</span></div><div class="line">2) <span class="string">"world"</span></div><div class="line">3) <span class="string">"hello"</span></div><div class="line">4) <span class="string">"foo"</span></div></pre></td></tr></table></figure>
<h3 id="14-Redis-Sunionstore-命令"><a href="#14-Redis-Sunionstore-命令" class="headerlink" title="14.Redis Sunionstore 命令"></a>14.Redis Sunionstore 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SUNIONSTORE destination key1 [key2]</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>所有给定集合的并集存储在 destination 集合中</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Sunionstore 命令将给定集合的并集存储在指定的集合 destination 中。如果 destination 已经存在，则将其覆盖。</p>
<h4 id="语法-13"><a href="#语法-13" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Sunionstore 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SUNIONSTORE DESTINATION KEY KEY1..KEYN</div></pre></td></tr></table></figure>
<h4 id="可用版本-13"><a href="#可用版本-13" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-13"><a href="#返回值-13" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;结果集中的元素数量。</p>
<h4 id="实例-14"><a href="#实例-14" class="headerlink" title="实例"></a>实例</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"world"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"hello"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset2 <span class="string">"bar"</span></div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SUNIONSTORE myset myset1 myset2</div><div class="line">(<span class="built_in">integer</span>) 1</div><div class="line">redis 127.0.0.1:6379&gt; SMEMBERS myset</div><div class="line">1) <span class="string">"bar"</span></div><div class="line">2) <span class="string">"world"</span></div><div class="line">3) <span class="string">"hello"</span></div><div class="line">4) <span class="string">"foo"</span></div></pre></td></tr></table></figure>
<h3 id="15-Redis-Sscan-命令"><a href="#15-Redis-Sscan-命令" class="headerlink" title="15.Redis Sscan 命令"></a>15.Redis Sscan 命令</h3><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>SSCAN key cursor [MATCH pattern] [COUNT count]</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<code>迭代集合中的元素</code></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Redis Sscan 命令用于迭代集合键中的元素。</p>
<h4 id="语法-14"><a href="#语法-14" class="headerlink" title="语法"></a>语法</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;redis Sscan 命令基本语法如下：</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SSCAN KEY [MATCH pattern] [COUNT count]</div></pre></td></tr></table></figure>
<h4 id="可用版本-14"><a href="#可用版本-14" class="headerlink" title="可用版本"></a>可用版本</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&gt;= 1.0.0</p>
<h4 id="返回值-14"><a href="#返回值-14" class="headerlink" title="返回值"></a>返回值</h4><p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;数组列表。</p>
<h4 id="实例-15"><a href="#实例-15" class="headerlink" title="实例"></a>实例</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 &quot;hello&quot;</div><div class="line">(integer) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 &quot;hi&quot;</div><div class="line">(integer) 1</div><div class="line">redis 127.0.0.1:6379&gt; SADD myset1 &quot;bar&quot;</div><div class="line">(integer) 1</div><div class="line">redis 127.0.0.1:6379&gt; sscan myset1 0 match h*</div><div class="line">1) &quot;0&quot;</div><div class="line">2) 1) &quot;hello&quot;</div><div class="line"> 2) &quot;h1&quot;</div></pre></td></tr></table></figure>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        

      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Redis/" rel="tag"># Redis</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/03/Redis/2. Redis 配置文件/" rel="next" title="Redis 配置文件">
                <i class="fa fa-chevron-left"></i> Redis 配置文件
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/09/03/Redis/22. Redis 有序集合(sorted set)/" rel="prev" title="Redis 有序集合(sorted set)">
                Redis 有序集合(sorted set) <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/images/0.png"
               alt="失落的乐章" />
          <p class="site-author-name" itemprop="name">失落的乐章</p>
           
              <p class="site-description motion-element" itemprop="description">失落的乐章的Blog</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/">
                <span class="site-state-item-count">627</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              <a href="/tags/index.html">
                <span class="site-state-item-count">38</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/hcldirgit" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#实例"><span class="nav-number">1.</span> <span class="nav-text">实例</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#Redis-集合命令"><span class="nav-number">2.</span> <span class="nav-text">Redis 集合命令</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-Redis-Sadd-命令"><span class="nav-number">2.1.</span> <span class="nav-text">1.Redis Sadd 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法"><span class="nav-number">2.1.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本"><span class="nav-number">2.1.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值"><span class="nav-number">2.1.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-1"><span class="nav-number">2.1.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-Redis-Scard-命令"><span class="nav-number">2.2.</span> <span class="nav-text">2.Redis Scard 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-1"><span class="nav-number">2.2.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-1"><span class="nav-number">2.2.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-1"><span class="nav-number">2.2.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-2"><span class="nav-number">2.2.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-Redis-Sdiff-命令"><span class="nav-number">2.3.</span> <span class="nav-text">3.Redis Sdiff 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-2"><span class="nav-number">2.3.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-2"><span class="nav-number">2.3.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-2"><span class="nav-number">2.3.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-3"><span class="nav-number">2.3.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#4-Redis-Sdiffstore-命令"><span class="nav-number">2.4.</span> <span class="nav-text">4.Redis Sdiffstore 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-3"><span class="nav-number">2.4.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-3"><span class="nav-number">2.4.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-3"><span class="nav-number">2.4.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-4"><span class="nav-number">2.4.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#5-Redis-Sinter-命令"><span class="nav-number">2.5.</span> <span class="nav-text">5.Redis Sinter 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-4"><span class="nav-number">2.5.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-4"><span class="nav-number">2.5.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-4"><span class="nav-number">2.5.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-5"><span class="nav-number">2.5.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#6-Redis-Sinterstore-命令"><span class="nav-number">2.6.</span> <span class="nav-text">6.Redis Sinterstore 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-5"><span class="nav-number">2.6.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-5"><span class="nav-number">2.6.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-5"><span class="nav-number">2.6.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-6"><span class="nav-number">2.6.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#7-Redis-Sismember-命令"><span class="nav-number">2.7.</span> <span class="nav-text">7.Redis Sismember 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-6"><span class="nav-number">2.7.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-6"><span class="nav-number">2.7.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-6"><span class="nav-number">2.7.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-7"><span class="nav-number">2.7.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#8-Redis-Smembers-命令"><span class="nav-number">2.8.</span> <span class="nav-text">8.Redis Smembers 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-7"><span class="nav-number">2.8.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-7"><span class="nav-number">2.8.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-7"><span class="nav-number">2.8.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-8"><span class="nav-number">2.8.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#9-Redis-Smove-命令"><span class="nav-number">2.9.</span> <span class="nav-text">9.Redis Smove 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-8"><span class="nav-number">2.9.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-8"><span class="nav-number">2.9.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-8"><span class="nav-number">2.9.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-9"><span class="nav-number">2.9.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#10-Redis-Spop-命令"><span class="nav-number">2.10.</span> <span class="nav-text">10.Redis Spop 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-9"><span class="nav-number">2.10.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-9"><span class="nav-number">2.10.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-9"><span class="nav-number">2.10.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-10"><span class="nav-number">2.10.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#11-Redis-Srandmember-命令"><span class="nav-number">2.11.</span> <span class="nav-text">11.Redis Srandmember 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-10"><span class="nav-number">2.11.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-10"><span class="nav-number">2.11.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-10"><span class="nav-number">2.11.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-11"><span class="nav-number">2.11.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#12-Redis-Srem-命令"><span class="nav-number">2.12.</span> <span class="nav-text">12.Redis Srem 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-11"><span class="nav-number">2.12.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-11"><span class="nav-number">2.12.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-11"><span class="nav-number">2.12.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-12"><span class="nav-number">2.12.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#13-Redis-Sunion-命令"><span class="nav-number">2.13.</span> <span class="nav-text">13.Redis Sunion 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-12"><span class="nav-number">2.13.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-12"><span class="nav-number">2.13.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-12"><span class="nav-number">2.13.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-13"><span class="nav-number">2.13.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#14-Redis-Sunionstore-命令"><span class="nav-number">2.14.</span> <span class="nav-text">14.Redis Sunionstore 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-13"><span class="nav-number">2.14.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-13"><span class="nav-number">2.14.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-13"><span class="nav-number">2.14.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-14"><span class="nav-number">2.14.4.</span> <span class="nav-text">实例</span></a></li></ol></li><li class="nav-item nav-level-3"><a class="nav-link" href="#15-Redis-Sscan-命令"><span class="nav-number">2.15.</span> <span class="nav-text">15.Redis Sscan 命令</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#语法-14"><span class="nav-number">2.15.1.</span> <span class="nav-text">语法</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#可用版本-14"><span class="nav-number">2.15.2.</span> <span class="nav-text">可用版本</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#返回值-14"><span class="nav-number">2.15.3.</span> <span class="nav-text">返回值</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#实例-15"><span class="nav-number">2.15.4.</span> <span class="nav-text">实例</span></a></li></ol></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">失落的乐章</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.1"></script>



  


  




	





  





  





  






  





  

  

  

  

  

  

</body>
</html>
